<?php
namespace Crm\Api;

use PhalApi\Api;
use Crm\Domain\Cms as DomainCms;

/**
 * 新闻文章服务类
 *
 * @author: luodong <751450467@qq.com> 2020-06-24
 */

class News extends Api {

	public function getRules() {
        return array(
            'getCategory' => array(
                'mall_id' 	=> array('name' => 'mall_id', 'type'=>'int','require'=>true,'desc'=>'商城ID')
            ),
            'getList' => array(
                'cid' 	=> array('name' => 'cid', 'type'=>'int','require'=>true,'desc'=>'类别ID'),
                'keyword'      => array('name' => 'keyword', 'type'=>'string','require'=>false,'desc'=>'关键字'),
                'pageSize'  => array('name' => 'pageSize', 'type'=>'int','require'=>false,'desc'=>'返回条数'),
                'page'      => array('name' => 'page', 'type'=>'int','require'=>false,'desc'=>'第几页'),
            ),
            'detail'=>array('id' => array('name' => 'id', 'type'=>'int','require'=>true,'desc'=>'信息ID')),
        );
	}

    /**
     * 返回分类
     */
    public function getCategory(){
        error_log("getCategory!", 0);
        $News = new DomainCms();
        $data = $News->getCategoryByMallId($this->mall_id);
        return $data;
    }

    /**
     * 返回资讯列表
     * @return obj 资讯信息
     */
    public function getList() {
        error_log("getList!", 0);
        $News = new DomainCms();
        $param = array(
            'cid'=>$this->cid,
            'keyword'=>$this->keyword,
            'page'=>$this->page,
            'pageSize'=>$this->pageSize
        );
        $data = $News->search($param);
        return $data;
    }

    /**
     * 获取资讯详情

     * @return array data 客户信息
     * @return int time 当前时间戳
     */
    public function detail()
    {
        error_log("detail!", 0);
        $domain = new DomainCms();
        $data = $domain->getContentInfo($this->id);

        return $data;

    }

}
